package javachongkao.集合.SplitintoTwoRows;

import java.util.Scanner;
//7-19 Split into Two Rows
//A straight line during class can cause a lot of trouble. The physical education teacher's usual method is to have the students count off as 1 or 2, and then the students who count as 2 take a step back. Now, given the student numbers in the straight line, can you output the student numbers after they are split into two rows?
//
//Input Format:
//The first line contains a number n, representing the number of students in the class. The number of students is at least 1 and does not exceed 100. The second line contains n numbers, representing the student numbers in the straight line.
//
//Output Format:
//Please output the student numbers of the two rows after the split, separated by spaces. Each row of students occupies two lines, with the students who counted off as 1 in the first row.
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 读取学生数量
        int n = scanner.nextInt();

        // 读取学生编号
        int[] students = new int[n];
        for (int i = 0; i < n; i++) {
            students[i] = scanner.nextInt();
        }

        // 输出第一行（编号为1的学生）
        StringBuilder row1 = new StringBuilder();
        // 输出第二行（编号为2的学生）
        StringBuilder row2 = new StringBuilder();

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {  // 偶数索引（0,2,4...）对应编号1的学生
                row1.append(students[i]).append(" ");
            } else {           // 奇数索引（1,3,5...）对应编号2的学生
                row2.append(students[i]).append(" ");
            }
        }

        // 输出结果，去除末尾多余的空格
        System.out.println(row1.toString().trim());
        System.out.println(row2.toString().trim());

        scanner.close();
    }
}
